package com.sky.config;

import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * Oss配置类
 *
 * */
@Configuration
@Data
@Slf4j
public class OssConfiguration {
    @Bean
    public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties) {
       // log.info("开始创建阿里云OSS客户端对象1：{}",aliOssProperties);
        log.info("开始创建阿里云OSS客户端对象2：{}",System.getenv("ALIYUN_OSS_ACCESS_KEY_ID"));
        log.info("开始创建阿里云OSS客户端对象3：{}",System.getenv("ALIYUN_OSS_ACCESS_KEY_SECRET"));
        log.info("开始创建阿里云OSS客户端对象4：{}",aliOssProperties.getEndpoint());
        log.info("开始创建阿里云OSS客户端对象5：{}",aliOssProperties.getBucketName());
      return new AliOssUtil( aliOssProperties.getEndpoint(),
              System.getenv("ALIYUN_OSS_ACCESS_KEY_ID"),
         System.getenv("ALIYUN_OSS_ACCESS_KEY_SECRET"),
         aliOssProperties.getBucketName());
    }
}
